home *** CD-ROM | disk | FTP | other *** search
- Path: familynews.cycor.ca!usenet
- From: gcaine@cycor.ca (gcaine)
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: Referances troubble
- Date: 23 Feb 1996 02:31:09 GMT
- Organization: Cycor Communications Inc., Coast to Coast Internet Services
- Message-ID: <1812.6626T1220T113@cycor.ca>
- References: <1266.6624T117T1455@himolde.no> <1143.6626T526T2599@cycor.ca>
- NNTP-Posting-Host: skt-as012.cycor.ca
- X-Newsreader: THOR 2.22 (Amiga;TCP/IP)
-
-
- >First change Tester to this:
-
- >void Tester(void *Testering)
- >{
- > printf("%d\n", Testering); /* prints the address of Testering, which
- > hasn't been Allocated yet */
- >
- > if (Testering = AllocMem(100, MEMF_CHIP | MEMF_CLEAR))
- > {
- > printf("%d\n", Testering); /* prints the address of Testering */
- > printf("%d\n", &Testering); /* prints the contents of Testering
- > which is 0 */
- > }
- >}
-
- Stupid, stupid me !!
-
- That's all wrong.
-
- First, printf("%d\n", &Testering will not print the contents of Testering,
- it will print the address of testering.
-
- printf("%d\n", Testering); will not print the address of Testering, it will
- print rhe memory location Testering points to.
-
- printf("%d\n", *Testering); Will print the contents of Testering.
-
- Here's a little example of pointers that might help straighten things out
- for you.
-
- --------------------------------Cut------------------------------
- #include <stdio.h>
-
- void main(int argc, char *argv[])
- {
- int someNumber;
- int *pointer;
-
- someNumber = 10;
-
- pointer = &someNumber;
-
- printf("the address of someNumber is %d\n", &someNumber);
- printf("pointer contains the address of someNumber: %d\n", pointer);
-
- printf("someNumber hold the value %d\n", someNumber);
- printf("You can also see the value with *pointer : %d\n", *pointer);
- }
-
- ------------------------------End Cut---------------------------------
-
- I believe for what you want to do, all you have to do is change
-
- void Tester(&Testering) to
- void Tester(void *Testering)
-
- I'm sorry about screwing up like that, I'll try to stop and think about
- what I'm saying next time.
-
- Gary Caine Member: Team AMIGA
-
-